package com.caseprocessing.model;

/**
 * 尺寸模型
 * 表示页面或元素的宽度和高度
 */
public class Dimensions {
    
    private int width;
    private int height;
    
    public Dimensions() {}
    
    public Dimensions(int width, int height) {
        this.width = width;
        this.height = height;
    }
    
    // Getters and Setters
    public int getWidth() { return width; }
    public void setWidth(int width) { this.width = width; }
    
    public int getHeight() { return height; }
    public void setHeight(int height) { this.height = height; }
    
    /**
     * 计算面积
     */
    public int getArea() {
        return width * height;
    }
    
    /**
     * 计算宽高比
     */
    public double getAspectRatio() {
        return height == 0 ? 0 : (double) width / height;
    }
    
    /**
     * 检查是否为标准A4尺寸 (2100x2970像素，按300DPI计算)
     */
    public boolean isA4Size() {
        return (width == 2100 && height == 2970) || 
               (width == 2970 && height == 2100);  // 横向
    }
    
    /**
     * 检查是否为横向页面
     */
    public boolean isLandscape() {
        return width > height;
    }
    
    /**
     * 检查是否为纵向页面
     */
    public boolean isPortrait() {
        return height > width;
    }
    
    @Override
    public String toString() {
        return String.format("Dimensions{width=%d, height=%d}", width, height);
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        
        Dimensions that = (Dimensions) obj;
        return width == that.width && height == that.height;
    }
    
    @Override
    public int hashCode() {
        return width * 31 + height;
    }
}